import { unique } from "./unique"

// 并 - 去重
// union([1, 2], ['x', 'y'], [5, 6], [], null, 1, 22) =>  [1, 2,  'x', 'y', 5, 6, 22]
export function union(...arrays: any[]): any[] {
  const result = []
  for (const array of arrays) {
    if (array == null) continue
    if (Array.isArray(array)) {
      for (const element of array) {
        result.push(element)
      }
    } else {
      result.push(array)
    }
  }
  return unique(result)
}

